package com.qidian.mes.sys.service.impl;

import com.qidian.mes.pojo.DictData;
import com.qidian.mes.sys.mapper.DictDataMapper;
import com.qidian.mes.sys.service.DictDataService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Author 戴着假发的程序员
 * @Company 起点编程
 * @Time 2023/10/25 15:03
 * @Description
 */
@Service
public class DictDataServiceimpl implements DictDataService {
    @Autowired
    private DictDataMapper dictDataMapper;
    @Override
    public MESResult get(Long dictId) {
        if (Objects.nonNull(dictId)){
            return MESResult.ok(dictDataMapper.get(dictId));
        }
        return MESResult.empty();
    }

    @Override
    public MESResult save(DictData dictData) {
        if (Objects.nonNull(dictData)){
            return MESResult.ok(dictDataMapper.save(dictData));
        }
        return null;
    }

    @Override
    public MESResult delete(Long dataId) {
        if (Objects.nonNull(dataId)){
            return MESResult.ok(dictDataMapper.delete(dataId));
        }
        return null;
    }

    @Override
    public MESResult deletes(Long[] dataIds) {
        if (dataIds.length > 0){
            return MESResult.ok(dictDataMapper.deletes(dataIds)+"");
        }
        return null;
    }

    @Override
    public MESResult update(DictData dictData) {
        if (Objects.nonNull(dictData)){
            return MESResult.updateIsOk(dictDataMapper.update(dictData));
        }
        return null;
    }

    @Override
    public MESResult getByDataId(Long dataId) {
        if (Objects.nonNull(dataId)){
            return MESResult.ok(dictDataMapper.getByDataId(dataId));
        }
        return null;
    }
}
